import { request } from "@/utils/request";

const apiPrefixPath = '/ht-smart-house'

/**
 * 获取预订订单列表
 * @returns {Promise | Promise<unknown>}
 */
export const getUserHouseOrderListApi = params => {
    return request({
        url: `${apiPrefixPath}/uploadFile/userQueryReserve`,
        method: 'POST',
        data: {
            page: params.page,
            size: params.pageSize
        }
    })
}

/**
 * 获取用户订单详情
 * @param id {String}
 * @returns {Promise | Promise<unknown>}
 */
export const getOrderDetailApi = id => {
    return request({
        url: `${apiPrefixPath}/uploadFile/userQueryReserveDetail?id=${id}`,
        method: 'GET'
    })
}

/**
 * 获取支付数据
 * @param data {Object}
 * @returns {Promise | Promise<unknown>}
 */
export const getOrderPayDataApi = data => {
    return request({
        url: `${apiPrefixPath}/uploadFile/userPayUserReserve`,
        method: 'POST',
        data
    })
}

/**
 * 用户申请退款
 * @param data
 * @returns {Promise<unknown>}
 */
export const userRefundApi = data => {
    return request({
        url: `${apiPrefixPath}/uploadFile/userRefundUserReserve`,
        method: 'POST',
        data
    })
}

/**
 * 撤销预约
 * @param id 订单id
 * @returns {Promise<unknown>}
 */
export const cancelOrderApi = id => {
    return request({
        url: `${apiPrefixPath}/uploadFile/userCancelReserve`,
        method: 'POST',
        type: "application/x-www-form-urlencoded",
        data: {id}
    })
}

/**
 * 提交对攻审核
 * @param data
 * @returns {Promise<unknown>}
 */
export const updateCertificateApi = data => {
    return request({
        url: `${apiPrefixPath}/uploadFile/userReservePublicTransfer`,
        method: 'POST',
        data: {
            id: data.id,
            images: data.imgPath,
            orderType: 0,
            payType: 2
        }
    })
}

/**
 * 获取用户订单消息数量
 * @returns {Promise | Promise<unknown>}
 */
export const getUsrOrderMsgApi = () => {
    return request({
        url: `${apiPrefixPath}/uploadFile/userQueryReservePay`,
        method: 'GET'
    })
}

/**
 * 用户取消支付
 * @param id
 * @returns {Promise<unknown>}
 */
export const userCancelPayApi = id => {
    return request({
        url: `${apiPrefixPath}/uploadFile/userCancelPay?id=${id}`,
        method: 'GET'
    })
}

export const getLeaseOrderListApi = params => {
    return request({
        url: `${apiPrefixPath}/facilitiesManage/getLeaseOrderInfo`,
        method: 'POST',
        data: {
            page:params.page,
            size:params.pageSize
        }
    })
}

/**
 * 提交租房对公转账
 * @param params
 * @returns {Promise<unknown>}
 */
export const updateLeaseOrderCertufucateApi = params => {
    return request({
        url: `${apiPrefixPath}/facilitiesManage/userLeaseOrderPublicTransfer`,
        method: 'POST',
        data: params
    })
}

/**
 * 用户支付租赁订单
 * @param params
 * @returns {Promise<unknown>}
 */
export const userPayLeaseOrderApi = params => {
    return request({
        url: `${apiPrefixPath}/facilitiesManage/userPayLeaseOrder`,
        method: 'POST',
        data: params
    })
}

/**
 * 用户取消支付租赁订单
 * @param orderIds
 * @returns {Promise<unknown>}
 */
export const userCancelPayLeaseOrderAPi = orderIds => {
    return request({
        url: `${apiPrefixPath}/facilitiesManage/userCancelPayLeaseOrder`,
        method: 'POST',
        data: {orderIds}
    })
}

export const getLeaseOrderMsgCountApi = () => {
    return request({
        url: `${apiPrefixPath}/facilitiesManage/getNotPayLeaseOrderCount`,
        method: 'GET'
    })
}
